import request from "@/utils/request";

const USER_BASE_URL = "/core/creditAmountRecord";

const creditAmountRecordApi = {
  /**
   * 授信额度记录分页查询
   * @param params 查询参数
   * @returns {Promise<PageResult<creditAmountRecordPageVO[]>>} 返回结果
   */
  getCreditAmountList: (params: creditAmountRecordPageQuery) => {
    const query = encodeURIComponent(JSON.stringify(params));
    return request<creditAmountRecordPageQuery, PageResult<creditAmountRecordPageVO[]>>({
      url: `${USER_BASE_URL}/getCreditAmountList?object=${query}`,
      method: "get",
    });
  },

  /**
   * 增加授信额度记录
   * @param params 保存参数
   * @returns 返回结果
   */
  addCreditAmountRecord: (params: creditAmountRecordVO) => {
    return request({
      url: `${USER_BASE_URL}/save`,
      method: "post",
      data: params,
    });
  },
};

export default creditAmountRecordApi;

/**
 * 授信额度记录分页查询参数
 * @property {string} companyCode 客户编码
 * @property {number} pageNum 当前页码
 * @property {number} pageSize 每页条数
 */
export interface creditAmountRecordPageQuery extends PageQuery {
  /**
   * 客户编码
   */
  companyCode: string;
  timeScopes?: string[];
}
/**
 * 授信额度记录分页查询结果
 * @property {number} amount 额度
 * @property {string} code 编码
 * @property {string} companyCode 客户编码
 * @property {string} createName 创建人
 * @property {string} createTime 创建时间
 * @property {number} createUser 创建人ID
 * @property {string} creditCode 授信编码
 * @property {number} creditType 授信类型
 * @property {number} id 主键
 * @property {number} isDelete 是否删除
 * @property {string} modifyName 修改人
 * @property {string} modifyTime 修改时间
 * @property {number} modifyUser 修改人ID
 * @property {number} pageNum 当前页码
 * @property {number} pageSize 每页条数
 * @property {string} remark 备注
 * @property {string[]} timeScopes 时间范围
 */
export interface creditAmountRecordPageVO {
  amount: number;
  code: string;
  companyCode: string;
  createName: string;
  createTime: string;
  createUser: number;
  creditCode: string;
  creditType: number;
  id: number;
  isDelete: number;
  modifyName: string;
  modifyTime: string;
  modifyUser: number;
  pageNum: number;
  pageSize: number;
  remark: string;
  timeScopes: string[];
}

/**
 * 授信额度记录添加参数
 * @property {number} amount 额度
 * @property {string} companyCode 客户编码
 * @property {string} creditCode 授信编码
 * @property {number} creditType 授信类型
 * @property {string} remark 备注
 * @property {string[]} timeScopes 时间范围
 */
export interface creditAmountRecordVO {
  amount: number;
  companyCode: string;
  creditCode?: string;
  creditType: number;
  remark?: string;
  timeScopes?: string[];
}
